
#include "string.h"

int main()
{
	cyq::string s1("hello world");
	cyq::string s2;
	cout << s1.c_str() << endl << s2.c_str() << endl;

	//迭代器
	//可读可写
	cyq::string::iterator it = s1.begin();
	while (it != s1.end())
	{
		(*it)++;
		it++;
	}

	it = s1.begin();
	while (it != s1.end())
	{
		cout << *it << " ";
		it++;
	}
	cout << endl;
	//只读
	const cyq::string s3("hello world");
	cyq::string::const_iterator itt = s3.begin();
	while (itt != s3.end())
	{
		cout << *itt << " ";
		itt++;
	}

	cout << endl;
	cout << s1[5] << s3[5] << endl;

	cyq::string s4("hello world");
	s4.push_back(' ');
	s4.push_back('#');
	s4.append(" xxxxxx");
	cout << s4.c_str() << endl;

	cyq::string s5("hello world");
	s5 += ' ';
	s5 += '#';
	s5 += " xxxxxx";
	cout << s5.c_str() << endl;

	cyq::string s6("hello world");
	s6.insert(0, 3, '#');
	cout << s6.c_str() << endl;

	cyq::string s7("hello world");
	s7.insert(0, "#####");
	cout << s7.c_str() << endl;

	cyq::string s8("hello world");
	s8.erase(5,3);
	cout << s8.c_str() << endl;

	cyq::string s9("hello world");
	s9.resize(8, 'x');
	cout << s9 << endl;
	cout << s9.c_str() << endl;
	s9.resize(20, 'y');
	cout << s9 << endl;
	cout << s9.c_str() << endl;

	//c语言中的字符串打印、拷贝都默认是到'\0'算作字符串的长度
	//string中以_size()为字符串的长度
	cyq::string ss("hello world");
	ss.push_back('\0');
	ss.append("xxxxxx");
	cyq::string copy(ss);
	cout << copy << endl;
	cout << copy.c_str() << endl;

	/*cyq::string s10;
	cin >> s10;

	cyq::string s11;
	cin >> s11;

	cout << (s11 < s10) << endl;
	cout << (s11 <= s10) << endl;
	cout << (s11 > s10) << endl;
	cout << (s11 >= s10) << endl;
	cout << (s11 == s10) << endl;
	cout << (s11 != s10) << endl;*/

	cyq::string s12("hello");
	cyq::string s13("xxxxxxxxx");
	s12 = s13;
	cout << s12 << endl;

	cyq::string s14("hello");
	cyq::string s15(s14);
	cout << s15 << endl;






}